package com.springboot.demo.service.impl;

import com.springboot.demo.exception.BusinessException;
import com.springboot.demo.mapper.CommonMapper;
import com.springboot.demo.service.CommonService;
import com.springboot.demo.utils.CommonUtils;
import com.springboot.demo.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wubc683
 * @desc
 * @date 2021-12-22 17:57
 */
@Service
public class CommonServiceImpl implements CommonService {
    @Autowired
    CommonMapper commonMapper;

    @Override
    public Map<Integer, Object> getAllProvinces() {
        Map<Integer, Object> allProvince = CommonUtils.getAllProvince();
        return allProvince;
    }

    @Override
    public Map<Integer, String> getAllCitiesByProvinceNum(Integer num) {
        // 省份从北京到宁夏，序号为0~33,传-1为获取所有市
        if (num < -1  || num >= 34) {
            throw new BusinessException(ResponseResult.PROVINCE_NUM_INVALID);
        }
        Map<Integer, String> cities = CommonUtils.getCities(num);
        return cities;
    }

    @Override
    public Map<Integer,String> getAllIndustryType() {
        Map<Integer,String> map = new HashMap<>();
        map.put(0,"暖通空调");
        map.put(1,"泵控设备");
        map.put(2,"锅炉");
        map.put(3,"工程器械");
        map.put(4,"物流设备");
        map.put(5,"电子制造");
        map.put(6,"锂电池");
        map.put(7,"环保设备");
        map.put(8,"包装机械");
        map.put(9,"组织机械");
        map.put(10,"停车设备");
        map.put(11,"机床");
        map.put(12,"印刷设备");
        map.put(13,"橡塑设备");
        map.put(14,"电力设备");
        map.put(15,"农业设备");
        map.put(16,"木工机械");
        map.put(17,"其他");
        return map;
    }

}
